
package com.lee.utils; 
 
import com.alibaba.fastjson.JSON; 
import com.lee.source.HbaseSource; 
 
import java.io.IOException; 
import java.util.HashMap; 
import java.util.List; 
import java.util.Map; 
 
public class RulesUtils { 
    private static String tableName = "marketing:rules";
    private static String family = "info";
    private static String confQualifier = "conf";
    private static String supportualifier = "support";
    private static String num = "num";
    public static void initMap() throws IOException {
        HbaseSource.truncate(tableName);
    }
 
    public static void setValueByKey(long index,List<String> from,List<String> to,double confValue,double supportValue) throws IOException {
        Map<String,String> keyMap = new HashMap<>();
        from.sort(String::compareTo);
        to.sort(String::compareTo);
        keyMap.put("from",from.toString());
        keyMap.put("to",to.toString());
 
        String keyStr = JSON.toJSONString(keyMap);
        HbaseSource.put(keyStr,tableName,family,confQualifier,String.valueOf(confValue));
        HbaseSource.put(keyStr,tableName,family,supportualifier,String.valueOf(supportValue));
        HbaseSource.put(keyStr,tableName,family,num,String.valueOf(index));
    }
 
 
 
 
 
} 
